<!DOCTYPE html>
<title>An SVGImageElement moved to a new document reloads the associated resource</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
setup(function() {
  let iframe = document.createElement('iframe');
  window.nested = document.body.appendChild(iframe);
});

async_test(function(t) {
  let image = document.createElementNS('http://www.w3.org/2000/svg', 'image');
  image.onerror = t.step_func(function() {
    let nestedDocument = nested.contentDocument;
    let nestedBase = nestedDocument.createElement('base');
    nestedBase.href = '../../images/';
    nestedDocument.head.appendChild(nestedBase);
    nestedDocument.adoptNode(image);
    image.onload = t.step_func_done();
    image.onerror = t.unreached_func('load event should fire');
  });
  image.onload = t.unreached_func('error event should fire');
  image.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'resources/blue-100.png');
});
</script>
